name: Test

on:
  push:
    branches:
      - main
    paths-ignore:
      - "docs/**"
      - "*.md"

  pull_request:
    types: [opened, synchronize, reopened, edited]
    paths-ignore:
      - "docs/**"
      - "*.md"

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  test:
    strategy:
      fail-fast: true
      matrix:
        python-version: ["3.9", "3.10", "3.11"]

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
      - name: Install deps
        run: |
          python -m pip install --upgrade pip
          python -m pip install ".[dev]"
      - name: Test with pytest
        run: |
          python -m pytest --exitfirst --verbose --failed-first --cov=.
